package org.tang.stock;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws Exception{
		FileReader syzg = new FileReader(new File("D:\\table.csv"));
		BufferedReader buffer = new BufferedReader(syzg);
		ArrayList<Stock> stocks = new ArrayList<Stock>();
		String line = null;
		line = buffer.readLine();
		while((line = buffer.readLine())!= null){
			Stock tmp = new Stock(line);
			//if(tmp.getVolume() != 0)
				stocks.add(tmp);
		}
		System.out.println("" + stocks.size());
		int count =0;
		int count2 =0;

		for(int i=15; i < stocks.size()-31; i++){
			int sum =0;
			int sum2 =0;
			int sum3 = 0;
			for(int j=0;j<30;j++){
				sum += stocks.get(i+j).getClosePrice();
				sum2 += stocks.get(i+j+1).getClosePrice();
				sum3 += stocks.get(i+j+2).getClosePrice();
			}
			
			if(stocks.get(i).getLowPrice()*1.1f < sum*1.0f /30 && sum > sum2 && sum2 > sum3)
			{
				count ++;
				int max = 0;
				for(int tt = 1; tt<=15;tt++ ){
					if(max < stocks.get(i-tt).getHightPrice())
						max = stocks.get(i-tt).getHightPrice();
				}
				if(sum*1.0f /30/1.1f*1.2f < max*1.0f){
					System.out.println("========="+stocks.get(i).getDate());
					count2++;
				}
				System.out.println(stocks.get(i).getDate());
			}
		}
		System.out.println("count1 = "+ count + ",count2 = "+count2);
	}
}
